package collection;

import java.util.Arrays;
import java.util.HashSet;

/**
 * @Description:HashSet 1、无序
 * 2、不可重复
 * @Author: hmm
 * @CreateDate: 2019/8/27
 * @UpdateUser:
 * @UpdateDate: 2019/8/27
 * @UpdateRemark: 修改备注
 * @Version: 1.0
 */
public class HashSetDemo {
    public static void main(String[] args) {
        HashSet<String> hashSet = new HashSet<>();
        hashSet.add("a");
        hashSet.add("b");
        /**
         * hashset添加重复的值不会添加 hashmap是替换
         */
        hashSet.add("a");
        System.out.println(Arrays.toString(hashSet.toArray()));
        Object clone = hashSet.clone();
        /**
         * hashset的clone是深度克隆
         */
        System.out.println(clone.toString());
        System.out.println(clone.equals(hashSet));
        System.out.println(clone == hashSet);

    }
}
